package client.comm.baoding.api

import client.comm.commlib.network.data.JsonResult
import client.comm.commlib.network.data.Ret
import client.comm.commlib.network.data.WlDetail
import client.comm.baoding.api.bean.*
import client.comm.baoding.api.bean.UserAddress
import client.comm.baoding.api.bean.UserInfo
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response
import retrofit2.http.*

interface Oserve {
    /**
     * 登录
     */
    @FormUrlEncoded
    @POST("/users/login/")
    suspend fun login(
        @Field("username") phone: String,
        @Field("password") password: String,
        @Field("device") device: String,
        @Field("device_id") device_id: String,
        @Field("device_name") device_name: String
    ): Response<JsonResult<Auth>>

    /**
     * 获取当前充值订单
     */
    @POST("/trading/current_recharge/")
    suspend fun current_recharge(): Response<JsonResult<CurrentRechargeOrder>>

    //创建订单
    @POST("/trading/recharge_orders/")
    @FormUrlEncoded
    suspend fun recharge_orders(
        @Field("price") price: String,
        @Field("w_type") w_type: String
    ): Response<JsonResult<Ret>>

    /**
     * 注册
     */
    @FormUrlEncoded
    @POST("/users/signup/")
    suspend fun register(
        @Field("username") username: String,
        @Field("phone") phone: String,
        @Field("password") password: String,
        @Field("password2") password2: String,
        @Field("captcha") captcha: String,
        @Field("invite") invite: String
    ): Response<JsonResult<Ret>>

    @POST("/trading/del_order/")
    @FormUrlEncoded
    suspend fun del_order(
        @Field("order_id") order_id: String,
    ): Response<JsonResult<Ret>>

    /**
     * 获取验证码
     */
    @FormUrlEncoded
    @POST("/common/captcha/")
    suspend fun getcode(
        @Field("phone") phone: String,
        @Field("ts") ts: String,
        @Field("sign") sign: String
    ): Response<JsonResult<Ret>>

    /**
     * 忘记密码
     */
    @FormUrlEncoded
    @POST("/users/forget_pwd/")
    suspend fun forget_pwd(
//        @Field("username") username: String,
        @Field("phone") phone: String,
        @Field("captcha") captcha: String,
        @Field("new_pwd") new_pwd: String,
        @Field("new_pwd2") new_pwd2: String
    ): Response<JsonResult<Ret>>

    /**
     * 修改密码
     */
    @FormUrlEncoded
    @POST("/users/reset_pwd/")
    suspend fun set_pwd(
        @Field("old_pwd") old_pwd: String,
        @Field("new_pwd") new_pwd: String,
        @Field("new_pwd2") new_pwd2: String
    ): Response<JsonResult<Ret>>

    /**
     * 修改支付密码
     */
    @FormUrlEncoded
    @POST("/users/forget_pay/")
    suspend fun forget_pay(
        @Field("username") username: String,
        @Field("phone") phone: String,
        @Field("captcha") captcha: String,
        @Field("new_pwd") new_pwd: String,
        @Field("new_pwd2") new_pwd2: String
    ): Response<JsonResult<Ret>>

    /**
     * 版本控制
     */
    @FormUrlEncoded
    @POST("/index/get_update/")
    suspend fun get_update(
        @Field("device") device: String,
        @Field("version") version: String
    ): Response<JsonResult<VersionRet>>

    @Multipart
    @POST("/common/upload/")
    suspend fun upload(
        @Part("description") requestBody: RequestBody,
        @Part file: MultipartBody.Part?
    ): Response<JsonResult<UploadRet>>

    /**
     * 设置头像
     */
    @FormUrlEncoded
    @POST("/users/user_avatar/")
    suspend fun user_avatar(
        @Field("avatar") avatar: String
    ): Response<JsonResult<Ret>>

    /**
     * 商品首页
     */
    @GET("/mall/goods_index/")
    suspend fun goods_index(
    ): Response<JsonResult<GoodsIndex>>

    @GET("/mall/goods_index/")
    suspend fun goods_index_p(
        @Query("page") page: Int
    ): Response<JsonResult<GoodsIndex>>

    /**
     * 用户信息
     */
    @GET("/users/user_info/")
    suspend fun userinfo(): Response<JsonResult<UserInfo>>

    /**
     * 数据补贴
     */
    @GET(" /index/level_income/")
    suspend fun level_income(): Response<JsonResult<LevelIncome>>

    /**
     * 分销排行榜
     */
    @GET(" /index/user_rank/")
    suspend fun user_rank(): Response<JsonResult<RankingList>>

    /**
     * 搜索
     */
    @FormUrlEncoded
    @POST("/mall/goods_search/")
    suspend fun searchRet(
        @Field("page") page: Int,
        @Field("goods_name") goods_name: String,
        @Field("price_status") price_status: String,
        @Field("sales_status") sales_status: String
    ): Response<JsonResult<SeartchRet>>

    //商品购买
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("/mall/buy_goods/")
    suspend fun goods_buy(@Body obj: RequestBody): Response<JsonResult<PayUrlBean>>


//    /**
//     * 支付宝支付
//     */
//    @FormUrlEncoded
//    @POST("/mall/alipay_post/") //alipay_post 非真实接口
//    suspend fun alipay_post(
//        @Field("order_sn") order_sn: String,
//        @Field("type") type: String
//    ): Response<JsonResult<String>>

    //获取用户地址
    @GET("/users/user_address/")
    suspend fun getAddress(): Response<JsonResult<UserAddress>>


    /**
     * 去支付
     */
    @FormUrlEncoded
    @POST("/mall/order_pay/")
    suspend fun order_pay(
        @Field("order_id") order_id: String
    ): Response<JsonResult<PayUrlBean>>

    /**
     * 检查支付
     */
    @FormUrlEncoded
    @POST("/mall/check_order_pay/")
    suspend fun check_order_pay(
        @Field("trade_no") trade_no: String
    ): Response<JsonResult<CheckPayBean>>

    /**
     * 取消订单
     */
    @FormUrlEncoded
    @POST("/mall/del_buy_order/")
    suspend fun del_buy_order(
        @Field("order_id") order_id: String
    ): Response<JsonResult<Ret>>

    /**
     * 确认订单
     */
    @FormUrlEncoded
    @POST("/mall/confirm_order/")
    suspend fun confirm_order(
        @Field("order_id") order_id: String
    ): Response<JsonResult<Ret>>

    //商品jil
    @POST("/mall/buy_order_record/")
    @FormUrlEncoded
    suspend fun buy_order_record(
        @Field("page") page: Int,
        @Field("status") status: Int
    ): Response<JsonResult<GoodsOrder>>

    //商品jil
    @GET("/mall/free_order_record/")
    suspend fun free_order_record(
        @Query("page") page: Int,
        @Query("status") status: Int
    ): Response<JsonResult<GoodsOrder>>

    /**
     *
     */
    @GET("/mall/v2.0/current_order/")
    suspend fun current_order(): Response<JsonResult<CurrOrderRet>>

    //验证支付密码
    @POST("/trading/user_pay_password/")
    @FormUrlEncoded
    suspend fun validatePayPwd(@Field("pay_pwd") pay_pwd: String): Response<JsonResult<Ret>>

    @POST("/trading/upload_img/")
    @FormUrlEncoded
    suspend fun upload_img(
        @Field("order_img") order_img: String,
        @Field("order_id") order_id: String,
        @Field("w_type") w_type: String,
    ): Response<JsonResult<Ret>>

    /**
     * 设置用户收货地址
     */
    @FormUrlEncoded
    @POST("/users/set_user_address/")
    suspend fun set_user_address(
        @Field("address_id") address_id: String,
        @Field("name") name: String,
        @Field("phone") phone: String,
        @Field("province") province: String?,
        @Field("city") city: String?,
        @Field("district") district: String?,
        @Field("place") place: String
    ): Response<JsonResult<Ret>>

    /**
     *
     */
    @FormUrlEncoded
    @POST("/mall/v2.0/seller_confirm/")
    suspend fun seller_confirm(
        @Field("order_id") order_id: String
    ): Response<JsonResult<Ret>>

    @POST("/users/del_address/")
    @FormUrlEncoded
    suspend fun del_address(
        @Field("address_id") address_id: String
    ): Response<JsonResult<Ret>>


    //设置默认收货地址
    @POST("/users/address_default/")
    @FormUrlEncoded
    suspend fun address_default(
        @Field("address_id") address_id: String
    ): Response<JsonResult<Ret>>

    //获取购物车
    @POST("/mall/shopping_cart/")
    @FormUrlEncoded
    suspend fun shopping_cart(
        @Field("page") page: String = "1",
    ): Response<JsonResult<BuyCartRet>>

    //删除购物车
    @POST("/mall/del_shopping_cart/")
    @FormUrlEncoded
    suspend fun del_shopping_cart(
        @Field("shopping_id") shopping_id: String,
    ): Response<JsonResult<Ret>>



    /**
     * tx
     *
     * w_type
     * 1：提现
     * 2：提税
     */
    @FormUrlEncoded
    @POST("/users/withdraw/")
    suspend fun tx(
        @Field("price") price: String,
        @Field("w_type") w_type: String,
        @Field("pay_type") pay_type: String,
        @Field("captcha") captcha: String,
        @Field("phone") phone: String,
    ): Response<JsonResult<Ret>>

    /**
     * tx
     *
     * w_type
     * 1：提现
     * 2：提税
     */
    @FormUrlEncoded
    @POST("/users/withdraw/")
    suspend fun tx2(
        @Field("price") price: String,
        @Field("w_type") w_type: String,
        @Field("pay_type") pay_type: String,
        @Field("captcha") captcha: String,
        @Field("phone") phone: String,
        @Field("withdraw_img") withdraw_img: String,
    ): Response<JsonResult<Ret>>

    /**
     * 资产记录
     * 1:钱包
     * 9：积分
     */
    @FormUrlEncoded
    @POST("/users/income_record/")
    suspend fun zcjl(
        @Field("page") page: Int,
        @Field("r_label") r_label: Int
    ): Response<JsonResult<Zcjl>>


    @FormUrlEncoded
    @POST("/users/income_record/")
    suspend fun zcjl2(
        @Field("page") page: Int,
        @Field("r_label") r_label: Int,
        @Field("r_type") r_type: Int
    ): Response<JsonResult<Zcjl>>

    /**
     * 资产记录
     */
    @GET("/trading/user_coin_record/")
    suspend fun user_coin_record(
        @Query("page") page: Int,
        @Query("status") status: Int,
    ): Response<JsonResult<HmjlRet>>

    /**
     * 用户积分
     */
    @GET("/trading/batch_trade/")
    suspend fun user_integral_record(
        @Query("page") page: Int,
        @Query("status") status: Int,
    ): Response<JsonResult<IntegralRet>>


    /**
     * 积分转换
     */
    @FormUrlEncoded
    @POST("/trading/batch_transfer/")
    suspend fun confirm_integral_transfer(
        @Field("batch_id") batch_id: String
    ): Response<JsonResult<Ret>>


    /**
     * 资产记录
     */
    @FormUrlEncoded
    @POST("/trading/recharge_record/")
    suspend fun recharge_record(
        @Field("page") page: Int,
        @Field("w_type") w_type: Int
    ): Response<JsonResult<Zcjl>>

    /**
     * 提现记录
     * w_type
     * 1.提现
     * 2.提税
     */
    @FormUrlEncoded
    @POST("/users/withdraw_record/")
    suspend fun withdraw_record(
        @Field("page") page: Int,
        @Field("w_type") w_type: String,
    ): Response<JsonResult<TxJl>>

    //类型详情
    @POST("/mall/goods_type_detail/")
    @FormUrlEncoded
    suspend fun goods_type_detail(
        @Field("page") page: Int,
        @Field("category_id") category_id: String,
    ): Response<JsonResult<CateGoods>>

    //类型详情
    @POST("/mall/goods_type_detail/")
    @FormUrlEncoded
    suspend fun goods_type_detail2(
        @Field("page") page: Int,
        @Field("category_id") category_id: String,
    ): Response<JsonResult<CateGoods>>

    //商品详情
    @POST("/mall/goods_detail/")
    @FormUrlEncoded
    suspend fun goods_detail(
        @Field("goods_id") goods_id: String,
        @Field("token") token: String?,
    ): Response<JsonResult<GoodsDetail>>

    //添加购物车
    @POST("/mall/add_shopping_cart/")
    @FormUrlEncoded
    suspend fun add_shopping_cart(
        @Field("goods_id") goods_id: String,
        @Field("num") num: String = "1",
    ): Response<JsonResult<Ret>>

    /**
     * 设置收款信息
     */
    @FormUrlEncoded
    @POST("/users/user_pay_account/")
    suspend fun user_pay_account(
        @Field("pay_type") pay_type: Int
    ): Response<JsonResult<PayAccount>>

    //完善资料
    @POST("/users/set_pay_account/")
    @FormUrlEncoded
    suspend fun real_names(
        @Field("real_name") real_name: String,
        @Field("pay_type") pay_type: String,
        @Field("pay_name") pay_name: String,
        @Field("bank_name") bank_name: String,
        @Field("pay_card") pay_card: String,
        @Field("pay_img") pay_img: String,
        @Field("phone") phone: String,
        @Field("captcha") captcha: String
    ): Response<JsonResult<Ret>>

    /**
     * 提现记录
     */
    @GET("/mall/mall_coupons/")
    suspend fun all_coupon(
    ): Response<JsonResult<AllCoupon>>

    /**
     * 领取优惠券
     */
    @FormUrlEncoded
    @POST("/mall/get_coupons/")
    suspend fun get_coupons(
        @Field("coupons_id") coupons_id: String
    ): Response<JsonResult<Ret>>

    /**
     * 我的优惠券
     */
    @FormUrlEncoded
    @POST("/users/user_coupons/")
    suspend fun user_coupons(
        @Field("page") page: Int,
        @Field("status") status: Int,
    ): Response<JsonResult<MeCoupon>>

    /**
     * 物流信息
     */
    @FormUrlEncoded
    @POST("/mall/deliver_info/")
    suspend fun deliver_info(
        @Field("order_id") order_id: String,
    ): Response<JsonResult<WlDetail>>

    /**
     * 当前订单
     */
    @GET("/mall/current_buy_order/")
    suspend fun current_buy_order(): Response<JsonResult<CurOrderDetail>>

    /**
     *
     */
    @FormUrlEncoded
    @POST("/mall/back_order_record/")
    suspend fun back_order_record(
        @Field("page") page: Int,
    ): Response<JsonResult<TuikuanList>>

    //退货
    @POST("/mall/goods_refunds/")
    @FormUrlEncoded
    suspend fun applyTuikuan(
        @Field("order_goods_id") order_goods_id: String,
        @Field("num") num: String,
        @Field("back_status") back_status: String,
        @Field("logistics_name") logistics_name: String,
        @Field("logistics_num") logistics_num: String,
    ): Response<JsonResult<Ret>>

    //团队
    @POST("/index/get_user_team/")
    @FormUrlEncoded
    suspend fun get_user_team(
        @Field("user_id") user_id: String,
        @Field("page") page: Int
    ): Response<JsonResult<TdBean>>

    //团队
    @POST("/index/get_user_team/")
    @FormUrlEncoded
    suspend fun get_user_team1(
        @Field("user_id") user_id: String,
        @Field("page") page: Int,
        @Field("status") status: Int
    ): Response<JsonResult<TdBean>>

    /**
     * 资产记录
     */
    @FormUrlEncoded
    @POST("/trading/hm_trade/")
    suspend fun hm_trade(
        @Field("number") number: String,
        @Field("w_type") w_type: Int
    ): Response<JsonResult<Ret>>

    /**
     *
     */
    @GET("/users/user_sign_in/")
    suspend fun user_sign_in(): Response<JsonResult<Ret>>


    /**
     * 转账
     */
    @FormUrlEncoded
    @POST("/trading/transfer/")
    suspend fun transfer(
        @Field("username") username: String,
        @Field("number") number: String
    ): Response<JsonResult<Ret>>

    // /users/reset_username/    post请求  参数 username
    // /users/user_out/   get请求  注销登录

    /**
     * 修改用户名
     */
    @FormUrlEncoded
    @POST("/users/reset_username/")
    suspend fun reset_username(
        @Field("username") username: String,
    ): Response<JsonResult<Ret>>

    /**
     * 注销登录
     */
    @GET("/users/user_out/")
    suspend fun user_out(): Response<JsonResult<Ret>>

    /**
     * 转账给 子/主 系统
     */
    @FormUrlEncoded
    @POST("/users/user_income_transfer/")
    suspend fun user_income_transfer(
        @Field("num") num: String,
    ): Response<JsonResult<Ret>>

    /**
     * 实名认证
     */
    @FormUrlEncoded
    @POST("/users/user_real_name/")
    suspend fun user_real_name(
        @Field("real_name") real_name: String,
        @Field("id_card") id_card: String,
        @Field("id_img") id_img: String,
    ): Response<JsonResult<Ret>>

}